package TextEditor.facade;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;

import javax.swing.JTextArea;


/**
 * Implementation of FileInterface to cut selected text
 * @author Yij_Zhan
 */
public class CutOperation implements FileInterface {

	Toolkit toolkit = Toolkit.getDefaultToolkit();
	Clipboard clipBoard = toolkit.getSystemClipboard();
	
	@Override
	public void fileOperation( JTextArea textArea) {

		textArea.requestFocusInWindow();
		String cutString = textArea.getSelectedText();
		StringSelection selection = new StringSelection(cutString);
		clipBoard.setContents(selection,null);

		textArea.replaceRange("",textArea.getSelectionStart(),textArea.getSelectionEnd());	
	}


}
